<!-- 算法服务卡片 -->
<template>
  <div :key="props.id" class="algo-item two cursor" @click="router.push('/algorithm-center/detail/' + props.id)">
    <div class="title elliptical-1" :title="props.algorithmName">{{ props.algorithmName }}</div>
    <div class="type-list">
      <div v-for="typeItem in props.typeNameString" :key="typeItem" class="type elliptical-1" :title="typeItem">
        {{ typeItem }}
      </div>
    </div>
    <div class="des" :title="props.algorithmDescribe">
      {{ props.algorithmDescribe }}
    </div>
    <div class="tag-list">
      <div v-for="tagItem in props.labelNameString" :key="tagItem" class="tag">
        <span class="elliptical-1" :title="tagItem">{{ tagItem }}</span>
      </div>
    </div>
    <img :src="props.downloadImageUrl" draggable="false" />
  </div>
</template>

<script lang="ts" setup>
  import { useRouter } from 'vue-router'

  import { AlgoServiceItem } from '../types'

  const props = withDefaults(defineProps<AlgoServiceItem>(), {})

  const router = useRouter()
</script>

<style lang="less" scoped>
  .algo-item {
    position: relative;
    overflow: hidden;
    padding: 20px 24px;
    // margin-bottom: 20px;
    width: 541.5px;
    // height: 2px;
    height: 189px;
    background-color: #fff;
    border: 1px solid #e0e5ee;
    border-radius: 8px;
    transition: all 0.25s;

    .title {
      width: 318px;
      font-size: 20px;
      line-height: 28px;
      color: #000;
      font-weight: 500;
    }

    .type-list {
      display: flex;
      align-items: center;
      margin-top: 8px;
      margin-left: -6px;
      height: 22px;
      font-size: 14px;
      color: rgba(25, 25, 48, 0.45);
      font-weight: 400;
      line-height: 22px;

      .type {
        position: relative;
        padding-left: 6px;
        max-width: 100px;

        & + .type {
          margin-left: 6px;

          &::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            width: 1px;
            height: 14px;
            background-color: #e8e8eb;
            transform: translateY(-50%);
          }
        }
      }
    }

    .des {
      display: -webkit-box;
      overflow: hidden;
      margin-top: 12px;
      width: 318px;
      height: 44px;
      font-size: 14px;
      text-overflow: ellipsis;
      white-space: normal;
      color: rgba(25, 25, 48, 0.75);
      font-style: normal;
      font-weight: 400;
      line-height: 22px;

      /* autoprefixer: ignore next */
      -webkit-box-orient: vertical;
      word-break: break-all;
      -webkit-line-clamp: 2;
    }

    .tag-list {
      display: flex;
      margin-top: 16px;
      height: 28px;

      .tag {
        padding: 3px 8px;
        max-width: 100px;
        height: 28px;
        font-size: 14px;
        color: @primary1;
        background: rgba(24, 104, 233, 0.08);
        border-radius: 6px;

        .fc();

        span {
          width: 100%;
        }

        & + .tag {
          margin-left: 6px;
        }
      }
    }

    img {
      position: absolute;
      right: 0;
      bottom: 0;
      display: block;
      width: 166px;
      height: 158px;
      object-fit: cover;
    }

    &:hover {
      border-color: transparent;
      box-shadow: 0 4px 24px rgba(163, 169, 183, 0.16);
    }
  }
</style>
